{% extends "base.html" %}
{% load pretty_user %}
{% load match %}
{% load partial_template %}

{% block additional_title %}
Head2Head
{% endblock %}

{% block nav %}
{% partial_template navigation.html selected_tab:"head2head" user:user perms:perms %}
{% endblock %}

{% block content %}
<div class="head2HeadLandingTitle">
    <center><h2>Head To Head</h2></center>
</div>
<div id="head2HeadMain">
    <div class="playerColumn">
        <div class="playerName">
            {{user1|pretty_user}} 
        </div>
        <div class="playerBioHeadShot">
            {% if user1.image %}<img src="{{ user1.image.url }}" width="200" height="200" alt="{{ user1.user.username }}"/>
            {% else %}<img src="{{ settings.MEDIA_URL }}images/users/unknown.jpg" width="200" height="200" alt="unknown"/>
            {% endif %} 
        </div>
        <div class="playerInfoRank">
            <span>{{standing1}}</span>
            Singles Ranking
        </div>
    </div>
    <table id="head2HeadMainTable" cellpadding="0" cellspacing="0">
        <tbody>
            <tr>
                <th colspan="2">
                    <table border="0" cellpadding="0" cellspacing="0">
                        <tbody>
                            <tr>
                                <th class="player1Rank" width="100">
                                    {{statisticsH2H.won}}
                                </th>
                                <th width="250">
                                	{% if statisticsH2H.draw == 0 %}
                                	:
                                	{% else %}
                                	({{ statisticsH2H.draw }})
                                	{% endif %}
                                </th>
                                <th class="player2Rank" width="100">
                                    {{statisticsH2H.lost}}
                                </th>
                            </tr>
                        </tbody>
                    </table>
                </th>
            </tr>
            <tr class="labelRow">
                <td colspan="2">
                    Pozicija
                </td>
            </tr>
            <tr class="infoRow">
                <td class="firstCell">
                    {{standing1}}
                </td>
                <td>
                    {{standing2}}
                </td>
            </tr>
            <tr class="labelRow">
                <td colspan="2">
                    Broj poena
                </td>
            </tr>
            <tr class="infoRow">
                <td class="firstCell">
                	{% if game_type_id == 1 %}
                    {{user1.chess_points}}
                    {% elif game_type_id == 2 %}
                    {{user1.tf_points}}
                    {% elif game_type_id == 3 %}
                    {{user1.football_points}}
                    {% elif game_type_id == 4 %}
                    {{user1.basket_points}}
                    {% else %}
                    {% endif %}
                </td>
                <td>
                	{% if game_type_id == 1 %}
                    {{user2.chess_points}}
                    {% elif game_type_id == 2 %}
                    {{user2.tf_points}}
                    {% elif game_type_id == 3 %}
                    {{user2.football_points}}
                    {% elif game_type_id == 4 %}
                    {{user2.basket_points}}
                    {% else %}
                    {% endif %}
                </td>
            </tr>
            <tr class="labelRow">
                <td colspan="2">
                    Pobede/nerešeno/porazi (u karijeri)
                </td>
            </tr>
            <tr class="infoRow">
                <td class="firstCell">
                    {{statistics1.won}}/{{ statistics1.draw }}/{{statistics1.lost}}
                </td>
                <td>
                    {{statistics2.won}}/{{ statistics2.draw }}/{{statistics2.lost}}
                </td>
            </tr>
            <tr class="labelRow">
                <td colspan="2">
                    Pobede (u karijeri %)
                </td>
            </tr>
            <tr class="infoRow">
                <td class="firstCell">
                    {{statistics1.percent_won|stringformat:".2f" }}%
                </td>
                <td>
                    {{statistics2.percent_won|stringformat:".2f" }}%
                </td>
            </tr>
        </tbody>
    </table>
    <div class="playerColumn">
        <div class="playerName">
            {{user2|pretty_user}} 
        </div>
        <div class="playerBioHeadShot">
            {% if user2.image %}<img src="{{ user2.image.url }}" width="200" height="200" alt="{{ user1.user.username }}"/>
            {% else %}<img src="{{ settings.MEDIA_URL }}images/users/unknown.jpg" width="200" height="200" alt="unknown"/>
            {% endif %} 
        </div>
        <div class="playerInfoRank">
            <span>{{standing2}}</span>
            Singles Ranking
        </div>
    </div>
</div>
<div class="head2HeadLandingTitle">
    <center><h2>Međusobni mečevi</h2></center>
</div>
<div class="commonProfileContainer">
    {% if h2hMatches %}
    <table class="tablesorter" id="mainTable">
        <thead>
            <th>
                Datum igranja
            </th>
            <th>
                Meč
            </th>
            <th>
                Rezultat
            </th>
        </thead>
        <tbody>
            {% for match in h2hMatches %}
            <tr>
                <td>
                    {{ match.date_played|date }} {{ match.date_played|time }} 
                </td>
                <td>
                    {{ match|match }} 
                </td>
                <td>
                    {{ match.result }}
                </td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
    {% else %}
    Nisu se sastajali! 
    {% endif %} 
</div>

<div class="head2HeadLandingTitle">
    <center><h2>Kretanje poena</h2></center>
</div>
<div>
	<img src="/mdcs/head2head/{{ game_type }}/{{ user1.id }}/{{ user2.id }}/timeline.png" alt="timeline"></img>
</div>

<div class="clear">
</div>
<!-- end clear -->
{% endblock %}
